package com.design.pattern.prototype;

import java.util.Date;

/**
 * @Description 简历类
 * @author ll
 * @createTime 2021/6/3  0:18 
 */
public class Resume implements Cloneable{

	private String name;
	private int age;
	private Work work;

	public Work getWork() {
		return work;
	}

	public void setWork(Work work) {
		this.work = work;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	/**
	 * 提供一个私有的构造方法，用来clone工作对象
	 * @param work
	 */
	private Resume(Work work) throws CloneNotSupportedException {
		this.work = (Work) work.clone();
	}

	public void setWorkInfo(Date beginWorkTime,Date endWorkTime,String company){
		work.beginWorkTime = beginWorkTime;
		work.endWorkTime = endWorkTime;
		work.company = company;
	}

	public Resume(String name,int age){
		this.name = name;
		this.age = age;
		work=new Work();
	}

	@Override
	protected Object clone() throws CloneNotSupportedException {
		Resume resume = new Resume(this.work);
		resume.name = this.name;
		resume.age = this.age;
		return resume;
	}

	public void showInfo(){
		System.out.println("名字是："+name+" 年龄是："+age +" 工作开始时间是："+work.beginWorkTime
				+ " 工作结束时间是："+work.endWorkTime +" 公司是："+work.company);
	}
}
